﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Windows.Forms;

using AimGameLibrary;

namespace AimGameEngine.NodeEditorObject
{
    partial class PropretyScreenControl : Form
    {
        NodeScreenControl screencontrol;
        public PropretyScreenControl(NodeScreenControl screencontrol)
        {
            InitializeComponent();
            this.comboBox1.SelectedIndex = 0;
            this.comboBox4.SelectedIndex = 0;
            
            this.screencontrol = screencontrol;
            this.comboBox1.SelectedItem = this.screencontrol.InputMode.ToString();

            this.comboBox4.SelectedIndex = Convert.ToInt32(screencontrol.LoadingIsSlow);

            this.comboBox2.Items.Clear();
            this.comboBox3.Items.Clear();
            foreach (String name in this.screencontrol.ListNameScreen)
            {
                this.comboBox2.Items.Add(name);
                this.comboBox3.Items.Add(name);
            }
            if (screencontrol.NameNextScreen != "NULL")
            {
                this.comboBox2.SelectedItem = screencontrol.NameNextScreen;
                this.comboBox3.SelectedItem = screencontrol.NameNextScreen;
            }
            else if (screencontrol.ListNameScreen.Count > 0)
            {
                this.comboBox2.SelectedIndex = 0;
                this.comboBox3.SelectedIndex = 0;
            }
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.virtualForm1.SelectedIndex = this.comboBox1.SelectedIndex;
        }

        private void okButton_Click(object sender, EventArgs e)
        {
            String tempString = (String)this.comboBox1.SelectedItem;

            if (tempString == NodeInputMode.AddScreen.ToString())
            {
                screencontrol.InputMode = NodeInputMode.AddScreen;
                screencontrol.NameNextScreen = (String)this.comboBox2.SelectedItem;
            }
            else if (tempString == NodeInputMode.ExitScreen.ToString())
            {
                screencontrol.InputMode = NodeInputMode.ExitScreen;
            }
            else if (tempString == NodeInputMode.ExitGame.ToString())
            {
                screencontrol.InputMode = NodeInputMode.ExitGame;
            }
            else if (tempString == NodeInputMode.LoadingScreen.ToString())
            {
                screencontrol.InputMode = NodeInputMode.LoadingScreen;
                screencontrol.NameNextScreen = (String)this.comboBox3.SelectedItem;
                screencontrol.LoadingIsSlow = Convert.ToBoolean(this.comboBox4.SelectedIndex);
            }            
        }

    }
}
